import { Component } from '/src/components/component/component.js';
import { TemplateManager } from '/src/util/templatemanager/templatemanager.js'

export class LogoComponent extends Component {
    constructor(container, options = {}) {
        super(container, options);

        this.options.format = 'YYYY:MM:DD HH:mm:ss'
        this.options.autoStart = true
        this.options.editable = false
        this.options.updateInterval = 1000
        this.options.templateUrl = '/src/components/component/custom/logo/logo.html'

        // 用于选择器定位
        this.fieldName = this.options.fieldName || `logo_${this.cid}`;
        this.label = this.options.label || 'logo';
        this.name = 'logo';
    }

    async init() {
        await this.render();
    }

    async render() {
    try {
      let html = await TemplateManager.loadTemplate(this.options.templateUrl, {
        cid: this.cid,
      });
      
      // 插入到容器
      this.container.html(html);
    } catch (error) {
      console.error('渲染logo组件时出错:', error);
      this.container.html(`<span class="error">加载失败: ${error.message}</span>`);
    }
  }
}